package com.tdam2011.grupo03.connection;


import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import com.tdam2011.grupo03.R;
import com.tdam2011.grupo03.activitys.Main;

import android.content.Intent;
public class NotificacionConexion {
	private static final int CONNECTION = 1;

	public static void notifyNetworkDisconnection(Context context) {
		
		String tickerText = context
				.getString(R.string.mensaje_ticker_desconexion);

		Notification notification = new Notification(R.drawable.icondes,
				tickerText, System.currentTimeMillis());
		
        Intent intent = new Intent (context,Main.class);
		PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,	intent, 0);

		notification.setLatestEventInfo(context, context
				.getString(R.string.titulo_desconexion), context
				.getString(R.string.mensaje_ticker_desconexion),
				pendingIntent);

		getManager(context).notify(CONNECTION, notification); 
	}

	public static void notifyNetworkConnection(Context context, String t) {
		String tickerText = context
				.getString(R.string.mensaje_ticker_conexion)+" "+t;

		Notification notification = new Notification(R.drawable.icondes,
				tickerText, System.currentTimeMillis());
        Intent intent = new Intent (context,Main.class);
		PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,	intent, 0);

		notification.setLatestEventInfo(context, context
				.getString(R.string.titulo_conexion)+" "+t, context
				.getString(R.string.mensaje_ticker_conexion)+" "+t,
				pendingIntent);

		getManager(context).notify(CONNECTION, notification);
	}

	public static void cancelAll(Context context) {
		getManager(context).cancel(CONNECTION);
	}

	private static NotificationManager getManager(Context context) {

		NotificationManager mNotificationManager = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);
		return mNotificationManager;
	}

}
